﻿<UserControl
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	mc:Ignorable="d"
	x:Class="SurveySez.EditorControl"
	x:Name="UserControl"
	d:DesignWidth="632" d:DesignHeight="446">
	<UserControl.Resources>
		<DataTemplate x:Key="GameHeaderViewModelTemplate">
			<StackPanel>
				<TextBlock Text="{Binding Name, TargetNullValue=&lt;New game&gt;}"/>
			</StackPanel>
		</DataTemplate>
		<DataTemplate x:Key="SurveyHeaderViewModelTemplate">
			<StackPanel>
				<TextBlock Text="{Binding Question}"/>
			</StackPanel>
		</DataTemplate>
		<DataTemplate x:Key="EditorSurveyHeaderViewModelTemplate">
			<StackPanel>
				<TextBlock Text="{Binding Question}"/>
			</StackPanel>
		</DataTemplate>
		<DataTemplate x:Key="ResponseViewModelTemplate">
			<Grid HorizontalAlignment="Stretch">
				<TextBlock Text="{Binding Answer}" VerticalAlignment="Center" d:LayoutOverrides="Width" HorizontalAlignment="Left"/>
				<TextBox Text="{Binding Answer}" d:LayoutOverrides="Width, Height" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="-4">
					<TextBox.Style>
						<Style TargetType="{x:Type TextBox}">
							<Setter Property="Visibility" Value="Hidden"/>
							<Style.Triggers>
								<DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}}" Value="True">
									<Setter Property="Visibility" Value="Visible"/>
								</DataTrigger>
							</Style.Triggers>
						</Style>
					</TextBox.Style>
				</TextBox>
			</Grid>
		</DataTemplate>
	</UserControl.Resources>

	<Grid x:Name="LayoutRoot">
		<Grid x:Name="LayoutRoot_Copy" d:DataContext="{d:DesignData /SampleData/EditorViewModelSampleData.xaml}">
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="0.536*"/>
				<ColumnDefinition Width="0.464*"/>
			</Grid.ColumnDefinitions>
			<Grid.RowDefinitions>
				<RowDefinition Height="Auto"/>
				<RowDefinition Height="0.278*"/>
				<RowDefinition Height="Auto"/>
				<RowDefinition Height="0.401*"/>
			</Grid.RowDefinitions>
			<Label Content="Surveys:" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="5,5,5,0"/>
			<Label Content="Games:" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="5,5,5,0"/>
			<ListBox Grid.Row="1" Margin="5" ItemTemplate="{DynamicResource EditorSurveyHeaderViewModelTemplate}" ItemsSource="{Binding Surveys}" SelectedItem="{Binding SelectedSurvey, Mode=TwoWay}"/>
			<ListBox Grid.Row="1" Grid.Column="1" Margin="5" ItemTemplate="{DynamicResource GameHeaderViewModelTemplate}" ItemsSource="{Binding Games}" SelectedItem="{Binding SelectedGame, Mode=TwoWay}"/>
			<Grid Grid.Row="3" DataContext="{Binding SurveyDetails}">
				<Grid.RowDefinitions>
					<RowDefinition Height="Auto"/>
					<RowDefinition Height="Auto"/>
					<RowDefinition Height="Auto"/>
					<RowDefinition Height="0.291*"/>
					<RowDefinition Height="Auto"/>
				</Grid.RowDefinitions>
				<Label Content="Question:" HorizontalAlignment="Left" Margin="5,5,5,0" d:LayoutOverrides="Height" VerticalAlignment="Top"/>
				<Label Content="Answers:" HorizontalAlignment="Left" Margin="5,5,5,0" Grid.Row="2" d:LayoutOverrides="Height" VerticalAlignment="Top"/>
				<TextBox Margin="5" TextWrapping="Wrap" Text="{Binding Question}" Grid.Row="1"/>
				<ListBox Grid.Row="3" Margin="5" ItemTemplate="{DynamicResource ResponseViewModelTemplate}" ItemsSource="{Binding Answers}" HorizontalContentAlignment="Stretch" SelectedItem="{Binding SelectedAnswer, Mode=TwoWay}"/>
				<StackPanel Orientation="Horizontal" Grid.Row="4" VerticalAlignment="Top" d:LayoutOverrides="Width" HorizontalAlignment="Left">
					<Button Content="New" Margin="5" Width="60" d:LayoutOverrides="Height" Command="{Binding NewAnswer}"/>
					<Button Content="Delete" Width="60" d:LayoutOverrides="Height" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Top" Command="{Binding DeleteAnswer}"/>
				</StackPanel>
				<StackPanel Orientation="Horizontal" d:LayoutOverrides="Width" Grid.Row="4" HorizontalAlignment="Right" VerticalAlignment="Top">
					<Button Content="Up" Width="60" HorizontalAlignment="Right" VerticalAlignment="Top" Height="21.277" Command="{Binding MoveAnswerUp}" Margin="5"/>
					<Button Content="Down" Width="60" HorizontalAlignment="Right" VerticalAlignment="Top" Command="{Binding MoveAnswerDown}" Margin="5"/>
				</StackPanel>
			</Grid>
			<Button Content="View &lt;&lt;" HorizontalAlignment="Right" Margin="0,5,5,0" Width="60" VerticalAlignment="Top" Grid.Row="3" Command="{Binding ViewSurvey}"/>
			<Grid Grid.Row="3" Grid.Column="1" DataContext="{Binding GameDetails}">
				<Grid.RowDefinitions>
					<RowDefinition Height="Auto"/>
					<RowDefinition Height="Auto"/>
					<RowDefinition Height="Auto"/>
					<RowDefinition/>
					<RowDefinition Height="Auto"/>
				</Grid.RowDefinitions>
				<Label Content="Surveys:" HorizontalAlignment="Left" Margin="5,5,0,0" Grid.Row="2"/>
				<ListBox Margin="5" Grid.Row="3" ItemTemplate="{DynamicResource SurveyHeaderViewModelTemplate}" ItemsSource="{Binding Surveys}" SelectedItem="{Binding SelectedSurvey, Mode=TwoWay}"/>
				<StackPanel Orientation="Horizontal" Grid.Row="4" d:LayoutOverrides="Height" Margin="0,-0.002">
					<Button Content="Add" Width="60" d:LayoutOverrides="Height" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Top" Command="{Binding AddSurvey}"/>
					<Button Content="Remove" ToolTip="v" Width="60" d:LayoutOverrides="Width, Height" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Top" Command="{Binding RemoveSurvey}"/>
				</StackPanel>
				<Label Content="Name" HorizontalAlignment="Left" Margin="5,5,5,0"/>
				<TextBox Margin="5" Grid.Row="1" TextWrapping="Wrap" Text="{Binding Name}"/>
				<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top" Grid.Row="4" d:LayoutOverrides="HorizontalAlignment">
					<Button Content="Up" Width="60" HorizontalAlignment="Right" VerticalAlignment="Top" Command="{Binding MoveSurveyUp}" Margin="5"/>
					<Button Content="Down" Width="60" HorizontalAlignment="Right" VerticalAlignment="Top" Command="{Binding MoveSurveyDown}" Margin="5"/>
				</StackPanel>
			</Grid>
			<StackPanel HorizontalAlignment="Left" Orientation="Horizontal" Grid.Row="2" VerticalAlignment="Top">
				<Button Content="New" Margin="5" Width="60" HorizontalAlignment="Left" VerticalAlignment="Top" Command="{Binding NewSurvey}"/>
				<Button Content="Delete" Margin="5" Width="60" HorizontalAlignment="Left" VerticalAlignment="Top" Command="{Binding DeleteSurvey}"/>
			</StackPanel>
			<StackPanel Grid.Column="1" Orientation="Horizontal" Grid.Row="2" d:LayoutOverrides="Width" HorizontalAlignment="Left" VerticalAlignment="Top">
				<Button Content="New" Margin="5" Width="60" HorizontalAlignment="Left" VerticalAlignment="Top" Command="{Binding NewGame}"/>
				<Button Content="Delete" Margin="5" Width="60" d:LayoutOverrides="Width" HorizontalAlignment="Left" VerticalAlignment="Top" Command="{Binding DeleteGame}"/>
			</StackPanel>
			<Button Content="Play" Grid.Column="1" HorizontalAlignment="Right" Margin="5" Grid.Row="2" Width="60" Command="{Binding PlayGame}" Height="21.2766666666667"/>
		</Grid>
	</Grid>
</UserControl>